package controller

import (
	"hft/Database/admin"
	"hft/Http/Models/request"
	services "hft/Http/Services"
	utils "hft/Http/Utils"

	"github.com/gin-gonic/gin"
)

type LouPanPhone struct{}

func (*LouPanPhone) Create(c *gin.Context) {
	var data *admin.LouPanPhone
	c.ShouldBindJSON(&data)

	err := services.LouPanPhoneService.Create(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*LouPanPhone) Edit(c *gin.Context) {
	var data *admin.LouPanPhone
	c.ShouldBindJSON(&data)

	err := services.LouPanPhoneService.Edit(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*LouPanPhone) List(c *gin.Context) {
	var paginate request.LouPanPhonePage

	c.ShouldBind(&paginate)

	data, err := services.LouPanPhoneService.List(&paginate)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(data, c)

}

func (*LouPanPhone) Delete(c *gin.Context) {

	var ids *request.IDS

	c.ShouldBindJSON(&ids)

	err := services.LouPanPhoneService.Delete(ids.IDS)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)

}

var LouPanPhoneController = new(LouPanPhone)
